package test;

import java.util.ArrayList;
import java.util.List;

import org.softmed.rest.config.Application;
import org.softmed.rest.config.Handler;
import org.softmed.rest.config.HttpMethod;
import org.softmed.rest.config.MimeTypeHandler;
import org.softmed.rest.config.Module;
import org.softmed.rest.config.Parameter;
import org.softmed.rest.config.Resource;

import restlet.description.convert.ConfigurationXMLConverter;

public class Main2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		ConfigurationXMLConverter conv = new ConfigurationXMLConverter();
		Application cfg = new Application();
		cfg.setActive(true);
		cfg.setUri("http://test.org");
		cfg.getModulePaths().add("http://test.org/module1");
		System.out.println(conv.toXML(cfg));

		List<Parameter> ps = new ArrayList<Parameter>();
		Parameter p = new Parameter();
		p.setName("name");
		p.setValue("value");
		ps.add(p);

		Handler handler = new Handler();
		handler.setPath("/path/to/handler.groovy");
		handler.setActive(false);
		handler.setUri("http://test.org/handler");
		handler.setParameters(ps);

		MimeTypeHandler mth = new MimeTypeHandler();
		mth.setUri("uri of mime type");
		mth.setMimeType("text/xml");
		mth.setHandler(handler);

		HttpMethod method = new HttpMethod();
		method.setUri("uri of method");
		method.setHandler(handler);
		method.getMimeTypeHandlers().add(mth);

		Resource resource = new Resource();
		resource.setUri("uri of resource");
		resource.setTargetUri("/clients/{id}");
		resource.setGet(method);

		Module module = new Module();
		module.setUri("uri of module");
		module.setName("costumer module");
		module.getResources().add(resource);

		System.out.println(conv.toXML(module));
	}

}
